﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>计划安排查看</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <link href="../CSS/fs_gallery.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/avalon.mobile.min.js"></script>
    <script src="../JS/MobileCom.js"></script>
    <script src="../JS/raty/jquery.raty.js?v=1.3"></script>
    <script src="../JS/fs_gallery.js"></script>
    <script>
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            //隐藏右上角按钮
            WeixinJSBridge.call('hideOptionMenu');
        });
        var width = 0;
        var strId = MobileCom.getQueryString("ID");
        var gzrbinfo = avalon.define({
            $id: "gzrbinfo",
            modelData: {},
            plData: {},
            plcount: 0,
            nowuser: "",
            imgurl: "",
            isbj: "",
            tpData: [],
            scpl: function (plel) {
                var tc = layer.open({
                    content: '确定要删除此评论吗？',
                    btn: ['确定', '取消'],
                    shadeClose: false,
                    yes: function () {
                        layer.close(tc);
                        var lg = $.loading({
                            content: '删除中...',
                        })
                        $.getJSON('/API/WXAPI.ashx?Action=DELTL&r=' + Math.random(), { P1: plel.ID }, function (resultData) {
                            lg.hide();
                            if (resultData.ErrorMsg == "") {
                                gzrbinfo.plData.remove(plel);
                                gzrbinfo.plcount = hdinfo.plcount - 1;
                                var el = $.tips({
                                    content: "删除成功",
                                    stayTime: 2000,
                                    type: "success"
                                })
                                el.on("tips:hide", function () {
                                    //window.location.reload();
                                })
                            }
                            else {
                                $.tips({
                                    content: "删除失败，原因：" + resultData.ErrorMsg,
                                    stayTime: 2000,
                                    type: "warn"
                                })
                            }
                        })
                    }, no: function () {
                    }
                })
            },
            fdtp: function (obj) {
                if (!$(".fs_gallery").html()) {
                    $('.mall_pcp').fsgallery();
                    $(obj).trigger("click");
                }
            },
            pl: function () {
                //var tc = layer.open({
                //    type: 1,
                //    //content:$("#bmxx").html(),
                //    //title: "评论",
                //    content: '<div class="ui-form ui-border-t" style="width:' + (width - 76) + 'px;"><div class="ui-form-item ui-border-b"><label style="width:50px">评分</label><div id="pc" style="padding-left: 50px;"></div></div><div class="ui-form-item ui-border-b" style="height:auto;min-height:44px;"><label style="width:50px">评论</label><textarea class="form-control" autofocus="autofocus" id="pl" placeholder="填写评论..." style="height:100px;margin-top:13px;padding-left: 50px;"></textarea></div></div>',
                //    //content: '<div class="ui-form-item ui-form-item-textarea ui-border-b" style="width:' + (width - 76) + 'px;height:200px"><textarea id="hdjjbjk" style="padding-left: 0;height:170px;border: 1px solid #e0e0e0;" placeholder="请输入评论内容">' + model.ctData.RBWCQK + '</textarea></div>',
                //    btn: ['确认', '取消'],
                //    shadeClose: false,
                //    yes: function () {
                //        var plpoints = 0;
                //        if ($('#pc').raty('score')) {
                //            plpoints = parseInt($('#pc').raty('score')) * 20;
                //        }
                //        var plcontent = $('#pl').val();
                //        if ($.trim(plcontent) == "") {
                //            alert("请输入评论内容");
                //            return "";
                //        }

                //        var lg = $.loading({
                //            content: '加载中...',
                //        })
                //        $.getJSON('/API/WXAPI.ashx?Action=ADDCOMENT&r=' + Math.random(), { "P1": plcontent, "Points": plpoints, "MsgType": "JHAP", "MsgLYID": strId }, function (resultData) {
                //            lg.hide();
                //            if (resultData.ErrorMsg == "") {
                //                gzrbinfo.plData.push(resultData.Result);
                //                gzrbinfo.plcount = gzrbinfo.plcount + 1;
                //                var el = $.tips({
                //                    content: "评论成功！！",
                //                    stayTime: 2000,
                //                    type: "success"
                //                })
                //                $("#content").val("");
                //            }
                //            else {
                //                var el = $.tips({
                //                    content: "评论失败！！",
                //                    stayTime: 2000,
                //                    type: "warn"
                //                })
                //            }
                //        })

                //        layer.close(tc);

                //    }, no: function () {
                //    }
                //})
                //$("#pc").raty();
                MobileCom.showComment("200", function (nr, pc) {
                    var lg = $.loading({
                        content: '保存中...',
                    })
                    $.getJSON('/API/WXAPI.ashx?Action=ADDCOMENT&r=' + Math.random(), { "P1": nr, "Points": pc, "MsgType": "JHAP", "MsgLYID": strId }, function (resultData) {
                        lg.hide();
                        if (resultData.ErrorMsg == "") {
                            gzrbinfo.plData.push(resultData.Result);
                            gzrbinfo.plcount = gzrbinfo.plcount + 1;
                            var el = $.tips({
                                content: "评论成功！！",
                                stayTime: 2000,
                                type: "success"
                            })
                        }
                        else {
                            var el = $.tips({
                                content: "评论失败！！",
                                stayTime: 2000,
                                type: "warn"
                            })
                        }
                    })

                })
            }
        });
        avalon.ready(function () {
            width = document.documentElement.clientWidth;
            if (strId != null) {
                var lg = $.loading({
                    content: '加载中...',
                })
                $.getJSON('/API/WXAPI.ashx?Action=GETJHAPMODEL&r=' + Math.random(), { P1: strId }, function (resultData) {
                    lg.hide();
                    if (resultData.ErrorMsg == "") {
                        gzrbinfo.modelData = resultData.Result;
                        gzrbinfo.plData = resultData.Result1;
                        gzrbinfo.plcount = resultData.Result1.length;
                        gzrbinfo.tpData = resultData.Result2;
                        //$.post("/API/SZHLAPI.ashx?Action=GetUserInfo&r=" + Math.random(), {}, function (data) {
                        //    lg.hide();
                        //    var data = $.parseJSON(data);
                        //    if (data.ErrorMsg == "") {
                        //        gzrbinfo.nowuser = data.Result.User.UserName;
                        //        if (data.Result.User.UserName == resultData.Result.CRUser) {
                        //            gzrbinfo.isbj = "Y";
                        //        }
                        //    }
                        //});
                    }
                })
            }

            $("button.ui-btn").click(function () {
                if ($("#content").val() == null || $("#content").val() == "") {
                    $.tips({
                        content: "请输入评论内容",
                        stayTime: 2000,
                        type: "warn"
                    })
                    return;
                }
                var lg = $.loading({
                    content: '加载中...',
                })
                $.getJSON('/API/WXAPI.ashx?Action=ADDCOMENT&r=' + Math.random(), { "P1": $("#content").val(), "MsgType": "JHAP", "MsgLYID": strId }, function (resultData) {
                    lg.hide();
                    if (resultData.ErrorMsg == "") {
                        gzrbinfo.plData.push(resultData.Result);
                        gzrbinfo.plcount = gzrbinfo.plcount + 1;
                        var el = $.tips({
                            content: "评论成功！！",
                            stayTime: 2000,
                            type: "success"
                        })
                        $("#content").val("");
                    }
                    else {
                        var el = $.tips({
                            content: "评论失败！！",
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            });
            $.post("/API/SZHLAPI.ashx?Action=GetUserInfo&r=" + Math.random(), {}, function (data) {

                var data = $.parseJSON(data);
                if (data.ErrorMsg == "") {
                    if (data.Result.QYinfo.FileServerUrl) {
                        var str = data.Result.QYinfo.FileServerUrl;
                        if (str.substr(str.length - 1, 1) != "/") {
                            str = str + "/";
                        }
                        gzrbinfo.imgurl = str;
                    }
                }
            })
        })

        function issc(str) {
            if (str == gzrbinfo.nowuser) {
                return '<div class="ui-badge-corner" style=" position: relative; " ms-click="scpl(el)">删除</div>';
            }
            else {
                return '';
            }
        }

        function back() {
            window.location.replace("UI_JHAP_LIST.html?r=" + Math.random());
        }

        function pjpf(pllist) {
            var zpf = 0;
            var zrs = 0;
            var pjf = 0;
            if (pllist.length > 0) {
                for (var i = 0; i < pllist.length; i++) {
                    if (pllist[i].Points && pllist[i].Points != "0") {
                        zpf = zpf + pllist[i].Points * 1;
                        zrs = zrs + 1;
                    }
                }

                if (zpf == 0) {
                    return '';
                }
                pjf = zpf / zrs;
                return '<div class="ui-form-item ui-border-b" style="height:auto;min-height:44px"><label>评分</label><span class="wspan">' + Math.round(pjf) + ' ' + pf(pjf) + '</span></div>';
            }
        }

        function pf(str) {
            var on = '<img  src="../JS/raty/images/star-on.png" style="width:16px;  margin-right: 0;">&nbsp;';
            var half = '<img  src="../JS/raty/images/star-half.png" style="width:16px;  margin-right: 0;">&nbsp;';
            var off = '<img  src="../JS/raty/images/star-off.png" style="width:16px;  margin-right: 0;">&nbsp;';
            if (str && str != "0") {

                var html = '';
                var n = parseInt(str / 20);
                var m = Math.ceil(str / 20);
                for (var i = 0; i < n; i++) {
                    html = html + on;
                }
                if (m > n) {
                    html = html + half;
                    n = n + 1;
                }
                for (var j = 0; j < 5 - n; j++) {
                    html = html + off;
                }

                return html;
            }
        }

    </script>
    <style>
        .ui-list > li {
            margin: 3px;
            padding-left: 15px;
        }

        .ui-form-item .wspan {
            width: 100%;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            padding-left: 95px;
        }

        .ms-controller, [ms-controller] {
            display: none;
        }

        .ui-form-item .span img {
            height: auto !important;
            width: auto\9 !important;
            width: 100% !important;
        }
        .ui-form-item .span {
            line-height: 1.5 !important;
            padding-bottom: 10px;
            overflow: hidden;
            word-wrap: break-word;
        }
    </style>
</head>
<body ms-controller="gzrbinfo">
    <header class="ui-header ui-header-stable ui-border-b">
        <i class="ui-icon-return" onclick="back()"></i><h1>计划安排查看</h1>
        <!--<a class="ui-btn ui-btn-primary" ms-if="isbj" ms-href="UI_GZRB_INPUT.html?ID={{modelData.ID}}" style="color:white">修改</a>-->
    </header>


    <section class="ui-container">

        <div class="ui-form ui-border-t">
            <div class="ui-form-item ui-border-b ">
                <label>
                    类型
                </label>
                <span class="wspan">{{modelData.LeiBie}}</span>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    时间
                </label>
                <span class="wspan">{{modelData.RBDate|date("yyyy-MM-dd")}}</span>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                <label>
                    内容
                </label>
                <span class="wspan "></span>
                <p class="span" ms-if="modelData.RBContent" ms-html="modelData.RBContent"></p>
                <div style="clear: both"></div>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                <label>
                    完成情况
                </label>
                <span class="wspan "></span>
                <p class="span" ms-if="modelData.RBWCQK" ms-html="modelData.RBWCQK"></p>
                <div style="clear: both"></div>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px" ms-if="tpData.size()>0">
                <label>
                    图片
                </label>
                <div class="wspan " style="padding-top:10px">
                    <span ms-repeat-fl="tpData">
                        <img ms-click="fdtp(this)" ms-if="MobileCom.xstp(fl.FileExtendName)" class="mall_pcp" ms-src="imgurl+'image/'+fl.FileMD5" style="width:60px;height:60px;padding-right: 5px;" />
                    </span>
                    <span ms-repeat-fls="tpData">
                        <img ms-click="fdtp(this)" ms-if="!MobileCom.xstp(fls.FileExtendName)" class="mall_pcp" ms-attr-src="'/MobileView/Images/qywd/'+fls.FileExtendName+'.png'" style="width:60px;height:60px;padding-right: 5px;" />
                    </span>
                </div>
            </div>
            {{pjpf(plData)|html}}
            <div class="ui-form-item ui-border-b">
                <label>
                    评论区
                </label>
                <span class="wspan">共 {{plcount}} 条评论</span>
                <a class="ui-btn-lg ui-btn-primary" ms-click="pl()" style="float: right; width: auto; height: 30px; line-height: 30px; margin-top: 7px;">评论</a>
            </div>
            <div class="ui-form ui-border-t" style="margin-bottom:44px">
                <ul class="ui-list ui-list-pure">
                    <li class="ui-border ui-label-list" ms-repeat-el="plData">
                        <div style="display: -webkit-box;">
                            <div class="ui-avatar-s">
                                <span ms-css-background-image="url(/Upload/TX/{{el.CRUser}}.jpg)"></span>
                            </div>
                            <div class="ui-list-info">
                                <h4>{{el.CRUserName}}</h4>
                            </div>
                            <div class="ui-list-info">
                                <p>{{el.CRDate|date("yyyy-MM-dd HH:mm")}}</p>
                            </div>
                            <!--{{issc(el.CRUser)|html }}-->
                        </div>
                        <p>{{pf(el.Points)|html}}</p>
                        <p class="ui-txt-justify" ms-html="el.MSGContent" style="overflow: hidden; word-wrap: break-word;"></p>
                    </li>
                </ul>
            </div>
        </div>

        <!--<div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
            <section class="ui-input-wrap ui-border-t" style="width:100%">
                <div class="ui-input ui-border-radius">
                    <input id="content" type="text" name="" value="" placeholder="我也说一句...">
                </div>
                <button class="ui-btn">评论</button>
            </section>
        </div>-->
    </section>
</body>
</html>
